package com.swanclouds.redfish.internal;

import com.swanclouds.api.types.ServiceType;
import com.swanclouds.core.transport.ClientConstants;
import com.swanclouds.model.common.redfish.CollectionResource;
import com.swanclouds.redfish.common.redfish.CollectionResourceModel;

/**
 *  * Description:
 *  * Author:      zhangliqiang@asiacom.net.cn
 *  * Date:        2022-07-16 10:26.
 *  
 */
public class BaseManagerService extends BaseRedfishService {

    public BaseManagerService() {
        super(ServiceType.MANAGERS);
    }

    private static ThreadLocal<String> managerContainer = new ThreadLocal<>();

    public String getManagerId() {
        if (managerContainer.get() != null) {
            return managerContainer.get();
        }
        CollectionResource resource = get(CollectionResourceModel.class, uri(ClientConstants.PATH_MANAGERS)).execute();
        return getResourceId(resource, managerContainer);
    }

}
